package com.meila.design.mode.observer;

import java.util.Observable;
import java.util.Observer;

/**
 * ***********************************************************
 *
 * @类名 : cms {person.java}
 * @DESCRIPTION : 被观察者对象
 * @AUTHOR :  meila-x->reese
 * @DATE : 2016/3/1
 * ***********************************************************
 */
public class NewPerson extends Observable {



    private String name ;

    private int age ;

    public NewPerson(String name, int age) {
        this.name = name;
        this.age = age;
        addObserver(new MyObserver());
    }

    public NewPerson() {
        this.addObserver(new MyObserver());
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.setChanged();
        this.notifyObservers();
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.setChanged();
        this.notifyObservers();
        this.age = age;
    }
}
